﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Locator.Silverlight.Client.Models.InventoryServiceReference;
using Locator.Silverlight.Client.Models.ViewModels.Elements;

namespace Locator.Silverlight.Client.Models
{
    public class InventoryRequestHelper
    {
        private readonly StoreViewModel storeViewModel;
        private readonly ProductViewModel productViewModel;

        public InventoryRequestHelper(StoreViewModel storeViewModel, ProductViewModel productViewModel)
        {
            // TODO: Complete member initialization
            this.storeViewModel = storeViewModel;
            this.productViewModel = productViewModel;
        }

        public InventoryServiceReference.InventoryRequest Request
        {
            get
            {
                InventoryRequest result = new InventoryRequest();
                if (storeViewModel.Id == StoreConstants.UsersStoresId)
                {
                    result.StoreNumberType = StoreNumberType.AllUsersStores;
                }
                else if (storeViewModel.Id == StoreConstants.AllStoresId)
                {
                    result.StoreNumberType = StoreNumberType.AllStores;
                }
                else
                {
                    result.StoreNumberType = StoreNumberType.IndividualStore;
                    result.StoreNumber = storeViewModel.Id;
                }

                if (productViewModel.Id == ProductConstants.UsersProductsId)
                {
                    result.ProductIdType = ProductIdType.AllUsersProducts;
                }
                else
                {
                    result.ProductIdType = ProductIdType.IndividualProduct;
                    result.ProductId = productViewModel.Id;
                }

                return result;
            }
        }
    }
}
